﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Schema.ScriptDom;
using Microsoft.Data.Schema.ScriptDom.Sql;


namespace teavch.Util.Formatter.SourceCode
{
	internal class SqlFormatter : CodeFormatter
	{

		Hashtable htable;// = new Hashtable();

		public SqlFormatter()
		{
			this.htable = new Hashtable();
			this.htable.Add( "$partition", "IdentifierPink" );
			this.htable.Add( "@@connections", "IdentifierPink" );
			this.htable.Add( "@@cpu_busy", "IdentifierPink" );
			this.htable.Add( "@@cursor_rows", "IdentifierPink" );
			this.htable.Add( "@@datefirst", "IdentifierPink" );
			this.htable.Add( "@@dbts", "IdentifierPink" );
			this.htable.Add( "@@error", "IdentifierPink" );
			this.htable.Add( "@@fetch_status", "IdentifierPink" );
			this.htable.Add( "@@identity", "IdentifierPink" );
			this.htable.Add( "@@idle", "IdentifierPink" );
			this.htable.Add( "@@io_busy", "IdentifierPink" );
			this.htable.Add( "@@langid", "IdentifierPink" );
			this.htable.Add( "@@language", "IdentifierPink" );
			this.htable.Add( "@@lock_timeout ", "IdentifierPink" );
			this.htable.Add( "@@max_connections ", "IdentifierPink" );
			this.htable.Add( "@@max_precision ", "IdentifierPink" );
			this.htable.Add( "@@nestlevel ", "IdentifierPink" );
			this.htable.Add( "@@options", "IdentifierPink" );
			this.htable.Add( "@@pack_received", "IdentifierPink" );
			this.htable.Add( "@@pack_sent", "IdentifierPink" );
			this.htable.Add( "@@packet_errors", "IdentifierPink" );
			this.htable.Add( "@@procid", "IdentifierPink" );
			this.htable.Add( "@@remserver ", "IdentifierPink" );
			this.htable.Add( "@@rowcount", "IdentifierPink" );
			this.htable.Add( "@@servername ", "IdentifierPink" );
			this.htable.Add( "@@servicename ", "IdentifierPink" );
			this.htable.Add( "@@spid", "IdentifierPink" );
			this.htable.Add( "@@textsize", "IdentifierPink" );
			this.htable.Add( "@@timeticks", "IdentifierPink" );
			this.htable.Add( "@@total_errors", "IdentifierPink" );
			this.htable.Add( "@@total_read", "IdentifierPink" );
			this.htable.Add( "@@total_write", "IdentifierPink" );
			this.htable.Add( "@@trancount", "IdentifierPink" );
			this.htable.Add( "@@version", "IdentifierPink" );
			this.htable.Add( "abs", "IdentifierPink" );
			this.htable.Add( "absolute", "IdentifierBlue" );
			this.htable.Add( "acos ", "IdentifierPink" );
			this.htable.Add( "action", "IdentifierBlue" );
			this.htable.Add( "ada", "IdentifierBlue" );
			this.htable.Add( "add", "IdentifierBlue" );
			this.htable.Add( "admin", "IdentifierBlue" );
			this.htable.Add( "after", "IdentifierBlue" );
			this.htable.Add( "aggregate", "IdentifierBlue" );
			this.htable.Add( "alias", "IdentifierBlue" );
			this.htable.Add( "all", "IdentifierBlue" );
			this.htable.Add( "allocate", "IdentifierBlue" );
			this.htable.Add( "alter", "IdentifierBlue" );
			this.htable.Add( "and", "IdentifierBlue" );
			this.htable.Add( "any", "IdentifierBlue" );
			this.htable.Add( "app_name", "IdentifierPink" );
			this.htable.Add( "applock_mode", "IdentifierPink" );
			this.htable.Add( "applock_test", "IdentifierPink" );
			this.htable.Add( "are", "IdentifierBlue" );
			this.htable.Add( "array", "IdentifierBlue" );
			this.htable.Add( "as", "IdentifierBlue" );
			this.htable.Add( "asc", "IdentifierBlue" );
			this.htable.Add( "ascii", "IdentifierPink" );
			this.htable.Add( "asensitive", "IdentifierBlue" );
			this.htable.Add( "asin", "IdentifierPink" );
			this.htable.Add( "assemblyproperty", "IdentifierPink" );
			this.htable.Add( "assertion", "IdentifierBlue" );
			this.htable.Add( "asymmetric", "IdentifierBlue" );
			this.htable.Add( "at", "IdentifierBlue" );
			this.htable.Add( "atan ", "IdentifierPink" );
			this.htable.Add( "atn2", "IdentifierPink" );
			this.htable.Add( "atomic", "IdentifierBlue" );
			this.htable.Add( "authorization", "IdentifierBlue" );
			this.htable.Add( "avg", "IdentifierPink" );
			this.htable.Add( "backup", "IdentifierBlue" );
			this.htable.Add( "before", "IdentifierBlue" );
			this.htable.Add( "begin", "IdentifierBlue" );
			this.htable.Add( "between", "IdentifierBlue" );
			this.htable.Add( "binary", "IdentifierBlue" );
			this.htable.Add( "binary_checksum", "IdentifierPink" );
			this.htable.Add( "bit", "IdentifierBlue" );
			this.htable.Add( "bit_length", "IdentifierBlue" );
			this.htable.Add( "blob", "IdentifierBlue" );
			this.htable.Add( "boolean", "IdentifierBlue" );
			this.htable.Add( "both", "IdentifierBlue" );
			this.htable.Add( "breadth", "IdentifierBlue" );
			this.htable.Add( "break", "IdentifierBlue" );
			this.htable.Add( "browse", "IdentifierBlue" );
			this.htable.Add( "bulk", "IdentifierBlue" );
			this.htable.Add( "by", "IdentifierBlue" );
			this.htable.Add( "call", "IdentifierBlue" );
			this.htable.Add( "called", "IdentifierBlue" );
			this.htable.Add( "cardinality", "IdentifierBlue" );
			this.htable.Add( "cascade", "IdentifierBlue" );
			this.htable.Add( "cascaded", "IdentifierBlue" );
			this.htable.Add( "case", "IdentifierBlue" );
			this.htable.Add( "cast", "IdentifierBlue" );
			this.htable.Add( "cast convert  ", "IdentifierPink" );
			this.htable.Add( "catalog", "IdentifierBlue" );
			this.htable.Add( "ceiling ", "IdentifierPink" );
			this.htable.Add( "certencoded", "IdentifierPink" );
			this.htable.Add( "certprivatekey", "IdentifierPink" );
			this.htable.Add( "char", "IdentifierBlue" );
			this.htable.Add( "char_length", "IdentifierBlue" );
			this.htable.Add( "character", "IdentifierBlue" );
			this.htable.Add( "character_length", "IdentifierBlue" );
			this.htable.Add( "charindex", "IdentifierPink" );
			this.htable.Add( "check", "IdentifierBlue" );
			this.htable.Add( "checkpoint", "IdentifierBlue" );
			this.htable.Add( "checksum", "IdentifierPink" );
			this.htable.Add( "checksum_agg", "IdentifierPink" );
			this.htable.Add( "class", "IdentifierBlue" );
			this.htable.Add( "clob", "IdentifierBlue" );
			this.htable.Add( "close", "IdentifierBlue" );
			this.htable.Add( "clustered", "IdentifierBlue" );
			this.htable.Add( "coalesce", "IdentifierBlue" );
			this.htable.Add( "col_length", "IdentifierPink" );
			this.htable.Add( "col_name", "IdentifierPink" );
			this.htable.Add( "collate", "IdentifierBlue" );
			this.htable.Add( "collation", "IdentifierBlue" );
			this.htable.Add( "collect", "IdentifierBlue" );
			this.htable.Add( "column", "IdentifierBlue" );
			this.htable.Add( "columnproperty", "IdentifierPink" );
			this.htable.Add( "commit", "IdentifierBlue" );
			this.htable.Add( "completion", "IdentifierBlue" );
			this.htable.Add( "compute", "IdentifierBlue" );
			this.htable.Add( "concat", "IdentifierPink" );
			this.htable.Add( "condition", "IdentifierBlue" );
			this.htable.Add( "connect", "IdentifierBlue" );
			this.htable.Add( "connection", "IdentifierBlue" );
			this.htable.Add( "connectionproperty", "IdentifierPink" );
			this.htable.Add( "constraint", "IdentifierBlue" );
			this.htable.Add( "constraints", "IdentifierBlue" );
			this.htable.Add( "constructor", "IdentifierBlue" );
			this.htable.Add( "contains", "IdentifierBlue" );
			this.htable.Add( "containstable", "IdentifierBlue" );
			this.htable.Add( "context_info", "IdentifierPink" );
			this.htable.Add( "continue", "IdentifierBlue" );
			this.htable.Add( "convert", "IdentifierBlue" );
			this.htable.Add( "corr", "IdentifierBlue" );
			this.htable.Add( "corresponding", "IdentifierBlue" );
			this.htable.Add( "cos", "IdentifierPink" );
			this.htable.Add( "cot", "IdentifierPink" );
			this.htable.Add( "count", "IdentifierPink" );
			this.htable.Add( "count_big", "IdentifierPink" );
			this.htable.Add( "covar_pop", "IdentifierBlue" );
			this.htable.Add( "covar_samp", "IdentifierBlue" );
			this.htable.Add( "create", "IdentifierBlue" );
			this.htable.Add( "cross", "IdentifierBlue" );
			this.htable.Add( "cube", "IdentifierBlue" );
			this.htable.Add( "cume_dist", "IdentifierBlue" );
			this.htable.Add( "current", "IdentifierBlue" );
			this.htable.Add( "current_catalog", "IdentifierBlue" );
			this.htable.Add( "current_date", "IdentifierBlue" );
			this.htable.Add( "current_default_transform_group", "IdentifierBlue" );
			this.htable.Add( "current_path", "IdentifierBlue" );
			this.htable.Add( "current_request_id", "IdentifierPink" );
			this.htable.Add( "current_role", "IdentifierBlue" );
			this.htable.Add( "current_schema", "IdentifierBlue" );
			this.htable.Add( "current_time", "IdentifierBlue" );
			this.htable.Add( "current_timestamp", "IdentifierPink" );
			this.htable.Add( "current_transform_group_for_type", "IdentifierBlue" );
			this.htable.Add( "current_user", "IdentifierPink" );
			this.htable.Add( "cursor", "IdentifierBlue" );
			this.htable.Add( "cursor_status", "IdentifierPink" );
			this.htable.Add( "cycle", "IdentifierBlue" );
			this.htable.Add( "data", "IdentifierBlue" );
			this.htable.Add( "database", "IdentifierBlue" );
			this.htable.Add( "database_principal_id", "IdentifierPink" );
			this.htable.Add( "databasepropertyex", "IdentifierPink" );
			this.htable.Add( "date", "IdentifierBlue" );
			this.htable.Add( "dateadd", "IdentifierPink" );
			this.htable.Add( "datediff", "IdentifierPink" );
			this.htable.Add( "datename", "IdentifierPink" );
			this.htable.Add( "datepart", "IdentifierPink" );
			this.htable.Add( "day", "IdentifierPink" );
			this.htable.Add( "db_id", "IdentifierPink" );
			this.htable.Add( "db_name", "IdentifierPink" );
			this.htable.Add( "dbcc", "IdentifierBlue" );
			this.htable.Add( "deallocate", "IdentifierBlue" );
			this.htable.Add( "dec", "IdentifierBlue" );
			this.htable.Add( "decimal", "IdentifierBlue" );
			this.htable.Add( "declare", "IdentifierBlue" );
			this.htable.Add( "default", "IdentifierBlue" );
			this.htable.Add( "deferrable", "IdentifierBlue" );
			this.htable.Add( "deferred", "IdentifierBlue" );
			this.htable.Add( "degrees", "IdentifierPink" );
			this.htable.Add( "delete", "IdentifierBlue" );
			this.htable.Add( "dense_rank", "IdentifierPink" );
			this.htable.Add( "deny", "IdentifierBlue" );
			this.htable.Add( "depth", "IdentifierBlue" );
			this.htable.Add( "deref", "IdentifierBlue" );
			this.htable.Add( "desc", "IdentifierBlue" );
			this.htable.Add( "describe", "IdentifierBlue" );
			this.htable.Add( "descriptor", "IdentifierBlue" );
			this.htable.Add( "destroy", "IdentifierBlue" );
			this.htable.Add( "destructor", "IdentifierBlue" );
			this.htable.Add( "deterministic", "IdentifierBlue" );
			this.htable.Add( "diagnostics", "IdentifierBlue" );
			this.htable.Add( "dictionary", "IdentifierBlue" );
			this.htable.Add( "difference", "IdentifierPink" );
			this.htable.Add( "disconnect", "IdentifierBlue" );
			this.htable.Add( "disk", "IdentifierBlue" );
			this.htable.Add( "distinct", "IdentifierBlue" );
			this.htable.Add( "distributed", "IdentifierBlue" );
			this.htable.Add( "domain", "IdentifierBlue" );
			this.htable.Add( "double", "IdentifierBlue" );
			this.htable.Add( "drop", "IdentifierBlue" );
			this.htable.Add( "dump", "IdentifierBlue" );
			this.htable.Add( "dynamic", "IdentifierBlue" );
			this.htable.Add( "each", "IdentifierBlue" );
			this.htable.Add( "element", "IdentifierBlue" );
			this.htable.Add( "else", "IdentifierBlue" );
			this.htable.Add( "end", "IdentifierBlue" );
			this.htable.Add( "end-exec", "IdentifierBlue" );
			this.htable.Add( "equals", "IdentifierBlue" );
			this.htable.Add( "errlvl", "IdentifierBlue" );
			this.htable.Add( "error_line", "IdentifierPink" );
			this.htable.Add( "error_message", "IdentifierPink" );
			this.htable.Add( "error_number", "IdentifierPink" );
			this.htable.Add( "error_procedure", "IdentifierPink" );
			this.htable.Add( "error_severity", "IdentifierPink" );
			this.htable.Add( "error_state", "IdentifierPink" );
			this.htable.Add( "escape", "IdentifierBlue" );
			this.htable.Add( "every", "IdentifierBlue" );
			this.htable.Add( "except", "IdentifierBlue" );
			this.htable.Add( "exception", "IdentifierBlue" );
			this.htable.Add( "exec", "IdentifierBlue" );
			this.htable.Add( "execute", "IdentifierBlue" );
			this.htable.Add( "exists", "IdentifierBlue" );
			this.htable.Add( "exit", "IdentifierBlue" );
			this.htable.Add( "exp", "IdentifierPink" );
			this.htable.Add( "external", "IdentifierBlue" );
			this.htable.Add( "extract", "IdentifierBlue" );
			this.htable.Add( "fetch", "IdentifierBlue" );
			this.htable.Add( "file", "IdentifierBlue" );
			this.htable.Add( "file_id", "IdentifierPink" );
			this.htable.Add( "file_idex", "IdentifierPink" );
			this.htable.Add( "file_name", "IdentifierPink" );
			this.htable.Add( "filegroup_id", "IdentifierPink" );
			this.htable.Add( "filegroup_name", "IdentifierPink" );
			this.htable.Add( "filegroupproperty", "IdentifierPink" );
			this.htable.Add( "fileproperty", "IdentifierPink" );
			this.htable.Add( "fillfactor", "IdentifierBlue" );
			this.htable.Add( "filter", "IdentifierBlue" );
			this.htable.Add( "first", "IdentifierBlue" );
			this.htable.Add( "float", "IdentifierBlue" );
			this.htable.Add( "floor ", "IdentifierPink" );
			this.htable.Add( "fn_virtualfilestats", "IdentifierPink" );
			this.htable.Add( "for", "IdentifierBlue" );
			this.htable.Add( "foreign", "IdentifierBlue" );
			this.htable.Add( "format", "IdentifierPink" );
			this.htable.Add( "formatmessage", "IdentifierPink" );
			this.htable.Add( "fortran", "IdentifierBlue" );
			this.htable.Add( "found", "IdentifierBlue" );
			this.htable.Add( "free", "IdentifierBlue" );
			this.htable.Add( "freetext", "IdentifierBlue" );
			this.htable.Add( "freetexttable", "IdentifierBlue" );
			this.htable.Add( "from", "IdentifierBlue" );
			this.htable.Add( "full", "IdentifierBlue" );
			this.htable.Add( "fulltextcatalogproperty", "IdentifierPink" );
			this.htable.Add( "fulltextserviceproperty", "IdentifierPink" );
			this.htable.Add( "fulltexttable", "IdentifierBlue" );
			this.htable.Add( "function", "IdentifierBlue" );
			this.htable.Add( "fusion", "IdentifierBlue" );
			this.htable.Add( "general", "IdentifierBlue" );
			this.htable.Add( "get", "IdentifierBlue" );
			this.htable.Add( "get_filestream_transaction_context", "IdentifierPink" );
			this.htable.Add( "getansinull", "IdentifierPink" );
			this.htable.Add( "getdate", "IdentifierPink" );
			this.htable.Add( "getutcdate", "IdentifierPink" );
			this.htable.Add( "global", "IdentifierBlue" );
			this.htable.Add( "go", "IdentifierBlue" );
			this.htable.Add( "goto", "IdentifierBlue" );
			this.htable.Add( "grant", "IdentifierBlue" );
			this.htable.Add( "group", "IdentifierBlue" );
			this.htable.Add( "grouping", "IdentifierPink" );
			this.htable.Add( "grouping_id", "IdentifierPink" );
			this.htable.Add( "has_perms_by_name", "IdentifierPink" );
			this.htable.Add( "having", "IdentifierBlue" );
			this.htable.Add( "hold", "IdentifierBlue" );
			this.htable.Add( "holdlock", "IdentifierBlue" );
			this.htable.Add( "host", "IdentifierBlue" );
			this.htable.Add( "host_id", "IdentifierPink" );
			this.htable.Add( "host_name", "IdentifierPink" );
			this.htable.Add( "hour", "IdentifierBlue" );
			this.htable.Add( "identity", "IdentifierBlue" );
			this.htable.Add( "identity_insert", "IdentifierBlue" );
			this.htable.Add( "identitycol", "IdentifierBlue" );
			this.htable.Add( "if", "IdentifierBlue" );
			this.htable.Add( "ignore", "IdentifierBlue" );
			this.htable.Add( "immediate", "IdentifierBlue" );
			this.htable.Add( "in", "IdentifierBlue" );
			this.htable.Add( "include", "IdentifierBlue" );
			this.htable.Add( "index", "IdentifierBlue" );
			this.htable.Add( "index_col", "IdentifierPink" );
			this.htable.Add( "indexkey_property", "IdentifierPink" );
			this.htable.Add( "indexproperty", "IdentifierPink" );
			this.htable.Add( "indicator", "IdentifierBlue" );
			this.htable.Add( "initialize", "IdentifierBlue" );
			this.htable.Add( "initially", "IdentifierBlue" );
			this.htable.Add( "inner", "IdentifierBlue" );
			this.htable.Add( "inout", "IdentifierBlue" );
			this.htable.Add( "input", "IdentifierBlue" );
			this.htable.Add( "insensitive", "IdentifierBlue" );
			this.htable.Add( "insert", "IdentifierBlue" );
			this.htable.Add( "int", "IdentifierBlue" );
			this.htable.Add( "integer", "IdentifierBlue" );
			this.htable.Add( "intersect", "IdentifierBlue" );
			this.htable.Add( "intersection", "IdentifierBlue" );
			this.htable.Add( "interval", "IdentifierBlue" );
			this.htable.Add( "into", "IdentifierBlue" );
			this.htable.Add( "is", "IdentifierBlue" );
			this.htable.Add( "is_member", "IdentifierPink" );
			this.htable.Add( "is_rolemember", "IdentifierPink" );
			this.htable.Add( "is_srvrolemember", "IdentifierPink" );
			this.htable.Add( "isdate", "IdentifierPink" );
			this.htable.Add( "isnull", "IdentifierPink" );
			this.htable.Add( "isnumeric", "IdentifierPink" );
			this.htable.Add( "isolation", "IdentifierBlue" );
			this.htable.Add( "iterate", "IdentifierBlue" );
			this.htable.Add( "join", "IdentifierBlue" );
			this.htable.Add( "key", "IdentifierBlue" );
			this.htable.Add( "kill", "IdentifierBlue" );
			this.htable.Add( "language", "IdentifierBlue" );
			this.htable.Add( "large", "IdentifierBlue" );
			this.htable.Add( "last", "IdentifierBlue" );
			this.htable.Add( "lateral", "IdentifierBlue" );
			this.htable.Add( "leading", "IdentifierBlue" );
			this.htable.Add( "left", "IdentifierPink" );
			this.htable.Add( "len", "IdentifierPink" );
			this.htable.Add( "less", "IdentifierBlue" );
			this.htable.Add( "level", "IdentifierBlue" );
			this.htable.Add( "like", "IdentifierBlue" );
			this.htable.Add( "like_regex", "IdentifierBlue" );
			this.htable.Add( "limit", "IdentifierBlue" );
			this.htable.Add( "lineno", "IdentifierBlue" );
			this.htable.Add( "ln", "IdentifierBlue" );
			this.htable.Add( "load", "IdentifierBlue" );
			this.htable.Add( "local", "IdentifierBlue" );
			this.htable.Add( "localtime", "IdentifierBlue" );
			this.htable.Add( "localtimestamp", "IdentifierBlue" );
			this.htable.Add( "locator", "IdentifierBlue" );
			this.htable.Add( "log", "IdentifierPink" );
			this.htable.Add( "log10 ", "IdentifierPink" );
			this.htable.Add( "login", "IdentifierBlue" );
			this.htable.Add( "lower", "IdentifierPink" );
			this.htable.Add( "ltrim", "IdentifierPink" );
			this.htable.Add( "map", "IdentifierBlue" );
			this.htable.Add( "match", "IdentifierBlue" );
			this.htable.Add( "max", "IdentifierPink" );
			this.htable.Add( "member", "IdentifierBlue" );
			this.htable.Add( "merge", "IdentifierBlue" );
			this.htable.Add( "method", "IdentifierBlue" );
			this.htable.Add( "min", "IdentifierPink" );
			this.htable.Add( "min_active_rowversion", "IdentifierPink" );
			this.htable.Add( "minute", "IdentifierBlue" );
			this.htable.Add( "mod", "IdentifierBlue" );
			this.htable.Add( "modifies", "IdentifierBlue" );
			this.htable.Add( "modify", "IdentifierBlue" );
			this.htable.Add( "module", "IdentifierBlue" );
			this.htable.Add( "month ", "IdentifierPink" );
			this.htable.Add( "multiset", "IdentifierBlue" );
			this.htable.Add( "names", "IdentifierBlue" );
			this.htable.Add( "national", "IdentifierBlue" );
			this.htable.Add( "natural", "IdentifierBlue" );
			this.htable.Add( "nchar", "IdentifierBlue" );
			this.htable.Add( "nclob", "IdentifierBlue" );
			this.htable.Add( "new", "IdentifierBlue" );
			this.htable.Add( "newid", "IdentifierPink" );
			this.htable.Add( "newsequentialid", "IdentifierPink" );
			this.htable.Add( "next", "IdentifierBlue" );
			this.htable.Add( "next value for", "IdentifierPink" );
			this.htable.Add( "no", "IdentifierBlue" );
			this.htable.Add( "nocheck", "IdentifierBlue" );
			this.htable.Add( "nonclustered", "IdentifierBlue" );
			this.htable.Add( "none", "IdentifierBlue" );
			this.htable.Add( "normalize", "IdentifierBlue" );
			this.htable.Add( "not", "IdentifierBlue" );
			this.htable.Add( "ntile", "IdentifierPink" );
			this.htable.Add( "null", "IdentifierBlue" );
			this.htable.Add( "nullif", "IdentifierBlue" );
			this.htable.Add( "numeric", "IdentifierBlue" );
			this.htable.Add( "object", "IdentifierBlue" );
			this.htable.Add( "object_definition", "IdentifierPink" );
			this.htable.Add( "object_id", "IdentifierPink" );
			this.htable.Add( "object_name", "IdentifierPink" );
			this.htable.Add( "object_schema_name", "IdentifierPink" );
			this.htable.Add( "objectproperty", "IdentifierPink" );
			this.htable.Add( "objectpropertyex", "IdentifierPink" );
			this.htable.Add( "occurrences_regex", "IdentifierBlue" );
			this.htable.Add( "octet_length", "IdentifierBlue" );
			this.htable.Add( "of", "IdentifierBlue" );
			this.htable.Add( "off", "IdentifierBlue" );
			this.htable.Add( "offsets", "IdentifierBlue" );
			this.htable.Add( "old", "IdentifierBlue" );
			this.htable.Add( "on", "IdentifierBlue" );
			this.htable.Add( "only", "IdentifierBlue" );
			this.htable.Add( "open", "IdentifierBlue" );
			this.htable.Add( "opendatasource", "IdentifierBlue" );
			this.htable.Add( "openquery", "IdentifierBlue" );
			this.htable.Add( "openrowset", "IdentifierBlue" );
			this.htable.Add( "openxml", "IdentifierPink" );
			this.htable.Add( "operation", "IdentifierBlue" );
			this.htable.Add( "option", "IdentifierBlue" );
			this.htable.Add( "or", "IdentifierBlue" );
			this.htable.Add( "order", "IdentifierBlue" );
			this.htable.Add( "ordinality", "IdentifierBlue" );
			this.htable.Add( "original_db_name", "IdentifierPink" );
			this.htable.Add( "original_login", "IdentifierPink" );
			this.htable.Add( "out", "IdentifierBlue" );
			this.htable.Add( "outer", "IdentifierBlue" );
			this.htable.Add( "output", "IdentifierBlue" );
			this.htable.Add( "over", "IdentifierBlue" );
			this.htable.Add( "overlaps", "IdentifierBlue" );
			this.htable.Add( "overlay", "IdentifierBlue" );
			this.htable.Add( "pad", "IdentifierBlue" );
			this.htable.Add( "parameter", "IdentifierBlue" );
			this.htable.Add( "parameters", "IdentifierBlue" );
			this.htable.Add( "parse", "IdentifierPink" );
			this.htable.Add( "parsename", "IdentifierPink" );
			this.htable.Add( "partial", "IdentifierBlue" );
			this.htable.Add( "partition", "IdentifierBlue" );
			this.htable.Add( "pascal", "IdentifierBlue" );
			this.htable.Add( "path", "IdentifierBlue" );
			this.htable.Add( "patindex", "IdentifierPink" );
			this.htable.Add( "percent", "IdentifierBlue" );
			this.htable.Add( "percent_rank", "IdentifierBlue" );
			this.htable.Add( "percentile_cont", "IdentifierBlue" );
			this.htable.Add( "percentile_disc", "IdentifierBlue" );
			this.htable.Add( "permissions", "IdentifierPink" );
			this.htable.Add( "pi", "IdentifierPink" );
			this.htable.Add( "pivot", "IdentifierGray" );
			this.htable.Add( "plan", "IdentifierBlue" );
			this.htable.Add( "position", "IdentifierBlue" );
			this.htable.Add( "position_regex", "IdentifierBlue" );
			this.htable.Add( "postfix", "IdentifierBlue" );
			this.htable.Add( "power ", "IdentifierPink" );
			this.htable.Add( "precision", "IdentifierBlue" );
			this.htable.Add( "prefix", "IdentifierBlue" );
			this.htable.Add( "preorder", "IdentifierBlue" );
			this.htable.Add( "prepare", "IdentifierBlue" );
			this.htable.Add( "preserve", "IdentifierBlue" );
			this.htable.Add( "primary", "IdentifierBlue" );
			this.htable.Add( "print", "IdentifierBlue" );
			this.htable.Add( "prior", "IdentifierBlue" );
			this.htable.Add( "privileges", "IdentifierBlue" );
			this.htable.Add( "proc", "IdentifierBlue" );
			this.htable.Add( "procedure", "IdentifierBlue" );
			this.htable.Add( "public", "IdentifierBlue" );
			this.htable.Add( "pwdcompare", "IdentifierPink" );
			this.htable.Add( "pwdencrypt", "IdentifierPink" );
			this.htable.Add( "quotename", "IdentifierPink" );
			this.htable.Add( "radians", "IdentifierPink" );
			this.htable.Add( "raiserror", "IdentifierBlue" );
			this.htable.Add( "rand", "IdentifierPink" );
			this.htable.Add( "range", "IdentifierBlue" );
			this.htable.Add( "rank", "IdentifierPink" );
			this.htable.Add( "read", "IdentifierBlue" );
			this.htable.Add( "reads", "IdentifierBlue" );
			this.htable.Add( "readtext", "IdentifierBlue" );
			this.htable.Add( "real", "IdentifierBlue" );
			this.htable.Add( "reconfigure", "IdentifierBlue" );
			this.htable.Add( "recursive", "IdentifierBlue" );
			this.htable.Add( "ref", "IdentifierBlue" );
			this.htable.Add( "references", "IdentifierBlue" );
			this.htable.Add( "referencing", "IdentifierBlue" );
			this.htable.Add( "regr_avgx", "IdentifierBlue" );
			this.htable.Add( "regr_avgy", "IdentifierBlue" );
			this.htable.Add( "regr_count", "IdentifierBlue" );
			this.htable.Add( "regr_intercept", "IdentifierBlue" );
			this.htable.Add( "regr_r2", "IdentifierBlue" );
			this.htable.Add( "regr_slope", "IdentifierBlue" );
			this.htable.Add( "regr_sxx", "IdentifierBlue" );
			this.htable.Add( "regr_sxy", "IdentifierBlue" );
			this.htable.Add( "regr_syy", "IdentifierBlue" );
			this.htable.Add( "relative", "IdentifierBlue" );
			this.htable.Add( "release", "IdentifierBlue" );
			this.htable.Add( "replace", "IdentifierPink" );
			this.htable.Add( "replicate", "IdentifierPink" );
			this.htable.Add( "replication", "IdentifierBlue" );
			this.htable.Add( "restore", "IdentifierBlue" );
			this.htable.Add( "restrict", "IdentifierBlue" );
			this.htable.Add( "result", "IdentifierBlue" );
			this.htable.Add( "return", "IdentifierBlue" );
			this.htable.Add( "returns", "IdentifierBlue" );
			this.htable.Add( "reverse", "IdentifierPink" );
			this.htable.Add( "revert", "IdentifierBlue" );
			this.htable.Add( "revoke", "IdentifierBlue" );
			this.htable.Add( "right", "IdentifierGray" );
			this.htable.Add( "role", "IdentifierBlue" );
			this.htable.Add( "rollback", "IdentifierBlue" );
			this.htable.Add( "rollup", "IdentifierBlue" );
			this.htable.Add( "round ", "IdentifierPink" );
			this.htable.Add( "routine", "IdentifierBlue" );
			this.htable.Add( "row", "IdentifierBlue" );
			this.htable.Add( "row_number ", "IdentifierPink" );
			this.htable.Add( "rowcount", "IdentifierBlue" );
			this.htable.Add( "rowcount_big", "IdentifierPink" );
			this.htable.Add( "rowguidcol", "IdentifierBlue" );
			this.htable.Add( "rows", "IdentifierBlue" );
			this.htable.Add( "rtrim", "IdentifierPink" );
			this.htable.Add( "rule", "IdentifierBlue" );
			this.htable.Add( "save", "IdentifierBlue" );
			this.htable.Add( "savepoint", "IdentifierBlue" );
			this.htable.Add( "schema", "IdentifierBlue" );
			this.htable.Add( "schema_id", "IdentifierPink" );
			this.htable.Add( "schema_name", "IdentifierPink" );
			this.htable.Add( "scope", "IdentifierBlue" );
			this.htable.Add( "scope_identity", "IdentifierPink" );
			this.htable.Add( "scroll", "IdentifierBlue" );
			this.htable.Add( "search", "IdentifierBlue" );
			this.htable.Add( "second", "IdentifierBlue" );
			this.htable.Add( "section", "IdentifierBlue" );
			this.htable.Add( "securityaudit", "IdentifierBlue" );
			this.htable.Add( "select", "IdentifierBlue" );
			this.htable.Add( "semantickeyphrasetable", "IdentifierBlue" );
			this.htable.Add( "semanticsimilaritydetailstable", "IdentifierBlue" );
			this.htable.Add( "semanticsimilaritytable", "IdentifierBlue" );
			this.htable.Add( "sensitive", "IdentifierBlue" );
			this.htable.Add( "sequence", "IdentifierBlue" );
			this.htable.Add( "serverproperty", "IdentifierPink" );
			this.htable.Add( "session", "IdentifierBlue" );
			this.htable.Add( "session_user", "IdentifierPink" );
			this.htable.Add( "set", "IdentifierBlue" );
			this.htable.Add( "set datefirst ", "IdentifierPink" );
			this.htable.Add( "set dateformat ", "IdentifierPink" );
			this.htable.Add( "set language ", "IdentifierPink" );
			this.htable.Add( "sets", "IdentifierBlue" );
			this.htable.Add( "setuser", "IdentifierBlue" );
			this.htable.Add( "shutdown", "IdentifierBlue" );
			this.htable.Add( "sign", "IdentifierPink" );
			this.htable.Add( "similar", "IdentifierBlue" );
			this.htable.Add( "sin", "IdentifierPink" );
			this.htable.Add( "size", "IdentifierBlue" );
			this.htable.Add( "smallint", "IdentifierBlue" );
			this.htable.Add( "some", "IdentifierBlue" );
			this.htable.Add( "soundex", "IdentifierPink" );
			this.htable.Add( "sp_helplanguage ", "IdentifierBrown" );
			this.htable.Add( "space", "IdentifierPink" );
			this.htable.Add( "specific", "IdentifierBlue" );
			this.htable.Add( "specifictype", "IdentifierBlue" );
			this.htable.Add( "sql", "IdentifierBlue" );
			this.htable.Add( "sqlca", "IdentifierBlue" );
			this.htable.Add( "sqlcode", "IdentifierBlue" );
			this.htable.Add( "sqlerror", "IdentifierBlue" );
			this.htable.Add( "sqlexception", "IdentifierBlue" );
			this.htable.Add( "sqlstate", "IdentifierBlue" );
			this.htable.Add( "sqlwarning", "IdentifierBlue" );
			this.htable.Add( "sqrt", "IdentifierPink" );
			this.htable.Add( "square ", "IdentifierPink" );
			this.htable.Add( "start", "IdentifierBlue" );
			this.htable.Add( "state", "IdentifierBlue" );
			this.htable.Add( "statement", "IdentifierBlue" );
			this.htable.Add( "static", "IdentifierBlue" );
			this.htable.Add( "statistics", "IdentifierBlue" );
			this.htable.Add( "stats_date", "IdentifierPink" );
			this.htable.Add( "stddev_pop", "IdentifierBlue" );
			this.htable.Add( "stddev_samp", "IdentifierBlue" );
			this.htable.Add( "stdev", "IdentifierPink" );
			this.htable.Add( "stdevp", "IdentifierPink" );
			this.htable.Add( "str", "IdentifierPink" );
			this.htable.Add( "structure", "IdentifierBlue" );
			this.htable.Add( "stuff", "IdentifierPink" );
			this.htable.Add( "submultiset", "IdentifierBlue" );
			this.htable.Add( "substring", "IdentifierPink" );
			this.htable.Add( "substring_regex", "IdentifierBlue" );
			this.htable.Add( "sum", "IdentifierPink" );
			this.htable.Add( "suser_id", "IdentifierPink" );
			this.htable.Add( "suser_name", "IdentifierPink" );
			this.htable.Add( "suser_sid", "IdentifierPink" );
			this.htable.Add( "suser_sname", "IdentifierPink" );
			this.htable.Add( "switchoffset ", "IdentifierPink" );
			this.htable.Add( "symmetric", "IdentifierBlue" );
			this.htable.Add( "sys.fn_builtin_permissions", "IdentifierGreen" );
			this.htable.Add( "sys.fn_get_audit_file", "IdentifierGreen" );
			this.htable.Add( "sys.fn_my_permissions", "IdentifierGreen" );
			this.htable.Add( "sysdatetime", "IdentifierPink" );
			this.htable.Add( "sysdatetimeoffset ", "IdentifierPink" );
			this.htable.Add( "system", "IdentifierBlue" );
			this.htable.Add( "system_user", "IdentifierPink" );
			this.htable.Add( "sysutcdatetime", "IdentifierPink" );
			this.htable.Add( "table", "IdentifierBlue" );
			this.htable.Add( "tablesample", "IdentifierBlue" );
			this.htable.Add( "tan", "IdentifierPink" );
			this.htable.Add( "temporary", "IdentifierBlue" );
			this.htable.Add( "terminate", "IdentifierBlue" );
			this.htable.Add( "textptr", "IdentifierPink" );
			this.htable.Add( "textsize", "IdentifierBlue" );
			this.htable.Add( "textvalid", "IdentifierPink" );
			this.htable.Add( "than", "IdentifierBlue" );
			this.htable.Add( "then", "IdentifierBlue" );
			this.htable.Add( "time", "IdentifierBlue" );
			this.htable.Add( "timestamp", "IdentifierBlue" );
			this.htable.Add( "timezone_hour", "IdentifierBlue" );
			this.htable.Add( "timezone_minute", "IdentifierBlue" );
			this.htable.Add( "to", "IdentifierBlue" );
			this.htable.Add( "todatetimeoffset ", "IdentifierPink" );
			this.htable.Add( "top", "IdentifierBlue" );
			this.htable.Add( "trailing", "IdentifierBlue" );
			this.htable.Add( "tran", "IdentifierBlue" );
			this.htable.Add( "transaction", "IdentifierBlue" );
			this.htable.Add( "translate", "IdentifierBlue" );
			this.htable.Add( "translate_regex", "IdentifierBlue" );
			this.htable.Add( "translation", "IdentifierBlue" );
			this.htable.Add( "treat", "IdentifierBlue" );
			this.htable.Add( "trigger", "IdentifierBlue" );
			this.htable.Add( "trim", "IdentifierBlue" );
			this.htable.Add( "truncate", "IdentifierBlue" );
			this.htable.Add( "try_cast  ", "IdentifierPink" );
			this.htable.Add( "try_convert  ", "IdentifierPink" );
			this.htable.Add( "try_parse", "IdentifierPink" );
			this.htable.Add( "tsequal", "IdentifierBlue" );
			this.htable.Add( "type_id", "IdentifierPink" );
			this.htable.Add( "type_name", "IdentifierPink" );
			this.htable.Add( "typeproperty", "IdentifierPink" );
			this.htable.Add( "uescape", "IdentifierBlue" );
			this.htable.Add( "under", "IdentifierBlue" );
			this.htable.Add( "unicode", "IdentifierPink" );
			this.htable.Add( "union", "IdentifierBlue" );
			this.htable.Add( "unique", "IdentifierBlue" );
			this.htable.Add( "unknown", "IdentifierBlue" );
			this.htable.Add( "unnest", "IdentifierBlue" );
			this.htable.Add( "unpivot", "IdentifierBlue" );
			this.htable.Add( "update", "IdentifierBlue" );
			this.htable.Add( "updatetext", "IdentifierBlue" );
			this.htable.Add( "upper", "IdentifierPink" );
			this.htable.Add( "usage", "IdentifierBlue" );
			this.htable.Add( "use", "IdentifierBlue" );
			this.htable.Add( "user", "IdentifierBlue" );
			this.htable.Add( "user_id", "IdentifierPink" );
			this.htable.Add( "user_name", "IdentifierPink" );
			this.htable.Add( "using", "IdentifierBlue" );
			this.htable.Add( "value", "IdentifierBlue" );
			this.htable.Add( "values", "IdentifierBlue" );
			this.htable.Add( "var", "IdentifierPink" );
			this.htable.Add( "var_pop", "IdentifierBlue" );
			this.htable.Add( "var_samp", "IdentifierBlue" );
			this.htable.Add( "varchar", "IdentifierBlue" );
			this.htable.Add( "variable", "IdentifierBlue" );
			this.htable.Add( "varp", "IdentifierPink" );
			this.htable.Add( "varying", "IdentifierBlue" );
			this.htable.Add( "view", "IdentifierBlue" );
			this.htable.Add( "waitfor", "IdentifierBlue" );
			this.htable.Add( "when", "IdentifierBlue" );
			this.htable.Add( "whenever", "IdentifierBlue" );
			this.htable.Add( "where", "IdentifierBlue" );
			this.htable.Add( "while", "IdentifierBlue" );
			this.htable.Add( "width_bucket", "IdentifierBlue" );
			this.htable.Add( "window", "IdentifierBlue" );
			this.htable.Add( "windows", "IdentifierBlue" );
			this.htable.Add( "with", "IdentifierBlue" );
			this.htable.Add( "within", "IdentifierBlue" );
			this.htable.Add( "within group", "IdentifierBlue" );
			this.htable.Add( "without", "IdentifierBlue" );
			this.htable.Add( "work", "IdentifierBlue" );
			this.htable.Add( "write", "IdentifierBlue" );
			this.htable.Add( "writetext", "IdentifierBlue" );
			this.htable.Add( "xact_state", "IdentifierPink" );
			this.htable.Add( "xmlagg", "IdentifierBlue" );
			this.htable.Add( "xmlattributes", "IdentifierBlue" );
			this.htable.Add( "xmlbinary", "IdentifierBlue" );
			this.htable.Add( "xmlcast", "IdentifierBlue" );
			this.htable.Add( "xmlcomment", "IdentifierBlue" );
			this.htable.Add( "xmlconcat", "IdentifierBlue" );
			this.htable.Add( "xmldocument", "IdentifierBlue" );
			this.htable.Add( "xmlelement", "IdentifierBlue" );
			this.htable.Add( "xmlexists", "IdentifierBlue" );
			this.htable.Add( "xmlforest", "IdentifierBlue" );
			this.htable.Add( "xmliterate", "IdentifierBlue" );
			this.htable.Add( "xmlnamespaces", "IdentifierBlue" );
			this.htable.Add( "xmlparse", "IdentifierBlue" );
			this.htable.Add( "xmlpi", "IdentifierBlue" );
			this.htable.Add( "xmlquery", "IdentifierBlue" );
			this.htable.Add( "xmlserialize", "IdentifierBlue" );
			this.htable.Add( "xmltable", "IdentifierBlue" );
			this.htable.Add( "xmltext", "IdentifierBlue" );
			this.htable.Add( "xmlvalidate", "IdentifierBlue" );
			this.htable.Add( "year", "IdentifierPink" );
			this.htable.Add( "zone", "IdentifierBlue" );
			this.htable.Add( "false", "IdentifierBlue" );
			this.htable.Add( "true", "IdentifierBlue" );
			this.htable.Add( "nolock", "IdentifierBlue" );

		}

		protected override StringBuilder Format( string input, bool quotedIdenfifiers, bool htmlBased )
		{
			StringBuilder sb = this.FormatNow( input, quotedIdenfifiers, htmlBased );
			return new StringBuilder( "<div class=\"divSqlCode\" ><code>" + sb.ToString() + "</code></div>" );
		}

		private StringBuilder FormatNow( string input, bool quotedIdenfifiers, bool htmlBased )
		{
			var _parser = new TSql100Parser( quotedIdenfifiers );
			StringBuilder result = null;
			string script;

			SqlScriptGeneratorOptions options = new SqlScriptGeneratorOptions();
			options.SqlVersion = SqlVersion.Sql100;
			options.KeywordCasing = KeywordCasing.Uppercase;
			options.IndentationSize = 2;
			options.AlignClauseBodies = true;
			options.IndentViewBody = true;
			options.AlignColumnDefinitionFields = true;
			options.AsKeywordOnOwnLine = true;
			options.NewLineBeforeFromClause = true;
			options.NewLineBeforeGroupByClause = true;
			options.NewLineBeforeHavingClause = true;
			options.NewLineBeforeJoinClause = true;
			options.NewLineBeforeOrderByClause = true;
			options.NewLineBeforeWhereClause = true;
			options.MultilineSelectElementsList = true;
			Sql100ScriptGenerator _scriptGen = new Sql100ScriptGenerator( options );

			IScriptFragment fragment;
			IList<ParseError> errors;

			fragment = _parser.Parse( new StringReader( input ), out errors );
			TSqlFragment tSqlFragment = null;
			if ( errors == null || errors.Count <= 0 )
			{
				_scriptGen.GenerateScript( fragment, out script );
				fragment = _parser.Parse( new StringReader( script ), out errors );
				if ( errors == null || errors.Count <= 0 )
				{
					tSqlFragment = fragment as TSqlFragment;
					IList<TSqlParserToken> _pList = _scriptGen.GenerateTokens( tSqlFragment );
					result = new StringBuilder();
					foreach ( TSqlParserToken p in tSqlFragment.ScriptTokenStream )
					{
						if ( p.TokenType == TSqlTokenType.Identifier )
						{
							string _identifierType = "";
							try
							{
								_identifierType = htable[ p.Text.ToLower() ] as string;
							}
							catch ( Exception  )
							{

							}
							if ( _identifierType == null || _identifierType.Trim() == "" )
								result.Append( "<span class=\"CodeSql" + p.TokenType.ToString() + "\" >" + p.Text + "</span>" );
							else
								result.Append( "<span class=\"CodeSql" + _identifierType + "\" >" + p.Text + "</span>" );

						}
						else if ( p.TokenType != TSqlTokenType.WhiteSpace )
						{
							result.Append( "<span class=\"CodeSql" + p.TokenType.ToString() + "\" >" + p.Text + "</span>" );
						}
						else
						{
							result.Append( p.Text.Replace( "\r\n", "<br/>" ).Replace( " ", "&nbsp;" ) );
						}
					}
					result = result.Replace( "<br/><br/><br/>", "<br/><br/>" );
				}
			}
			else
			{
				StringBuilder sb = new StringBuilder();
				sb.Append( "error:" );
				foreach ( var error in errors )
				{
					sb.AppendLine( error.Message );
					sb.AppendLine( "offset " + error.Offset.ToString() );
				}
				result = sb;
			}
			return result;
		}

		protected override string[] GetTokens()
		{
			string[] s = Enum.GetNames( typeof( TSqlTokenType ) );
			return s;
		}

	}
}
